<template>
  <header class="header">
    <div class="container">
      <div class="flex-between">
        <div class="flex gap-20">
          <router-link to="/" class="logo">一个</router-link>
          <nav class="nav">
            <router-link to="/library" class="nav-link">书库</router-link>
            <router-link to="/upload" class="nav-link">上传</router-link>
          </nav>
        </div>
        
        <div class="flex gap-10">
          <SearchBox />
          <button @click="handleLogout" class="btn">退出</button>
        </div>
      </div>
    </div>
  </header>
</template>

<script setup>
import { useAuthStore } from '@/stores/auth'
import { useRouter } from 'vue-router'
import SearchBox from '@/components/SearchBox.vue'

const authStore = useAuthStore()
const router = useRouter()

const handleLogout = () => {
  authStore.logout()
  router.push('/login')
}
</script>

<style scoped>
.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  letter-spacing: 1px;
}

.nav {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.router-link-active {
  color: var(--primary-color);
}
</style>